Made By Arsalan Aslam
Webmaster of Code
Master
In this tutorial I'll cover the essential things which are required to make a simple animation (for the game) in VB. Keep in mind whenever you are going to make a game in VB, first change the
ScaleMode property to 3 - Pixels
AutoRedraw property to TRUE
In the included sample source code I have 6 picture boxes which have the properties set to the above values.
Three picture boxes are for sprite
(characters)
![]()
one for mask ![]()
and other two for background picture

Instead of using VB function to draw the sprite
to the background picture we will use API function BitBlt (Bit Block Transfer)
which is faster than the normal VB functions. The syntax for this function is,
BitBlt( hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop )
| hdcDest nXDestn YDest nWidth nHeight hdcSrc nXSrc nYSrc dwRop
|
handle
to destination device context x-coordinate of destination rectangle's upper-left corner y-coordinate of destination rectangle's upper-left corner width of destination rectangle height of destination rectangle handle to source device context x-coordinate of source rectangle's upper-left y-coordinate of source rectangle's upper-left raster operation code We will use only three raster operation code MERGEPAINT SRCCAND SRCCOPY |
So if we want to Blt the picture (rectangle picture) of 32x32 pixels at 0,0
co-ordinate, we will use
BitBlt hdcDest, 0, 0, 32, 32, hdcSrc, 0, 0, SRCCOPY
where hdcDest is handle to destination device
context
and hdcSrc is handle to source device context
But if we want to draw round or other picture which is not a rectangle we have
to use
BitBlt hdcDest, 0, 0, 32, 32, hdcMask, 0, 0,
MERGEPAINT
BitBlt hdcDest, 0, 0, 32, 32, hdcSrc, 0, 0, SRCCAND
where hdcMask is handle to mask's device context
Now take a look at the included source code which will give you practical knowledge.
If you have any comment, question or suggestion please let me know